<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<title>旅游信息管理</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/dialog.css" rel="stylesheet" type="text/css" />

</head>

<body>
<div align="center"><!--筛选部分-->

<div
	style="height: 32px; background: #F8F8F8; border-bottom: 2px solid #FF6600;">
<span
	style="float: left; font-size: 18px; font-weight: bold; padding: 5px;">新闻资讯</span>
<span style="float: right; padding: 5px; margin-right: 10px;">您当前：首页
&gt;&gt;&gt; 新闻资讯 </span></div>

<div class="showlist" id="content">
<ul>
<?php //加载配置文件

include 'config.php';
$link = mysql_connect(HOST,DBUSER,DBPASS) or die('连接失败亲');
mysql_select_db(DBNAME,$link);
mysql_set_charset('utf8');
//连接数据库计算共有多少页
$sqls = "SELECT count(id) FROM t_news ";
$results = mysql_query($sqls);
if(!empty($results) && mysql_num_rows($results)>0){
	$rows = mysql_fetch_assoc($results);
	$alldata= $rows['count(id)'];
}
//当前页
$page = empty($_GET['page']) ? 1 : $_GET['page'];
if($page<0){
	$page = 1;
}
//每页有多少条数据
$pageCount =12;
//计算有多少页
$allPage = ceil($alldata/$pageCount);

//判断当前页数是否大于总页数
if($page>$allPage){
	$page=$allPage;
}
//sql

$startPage = ($page-1)*$pageCount;
$sql = "SELECT * FROM t_news  ORDER BY id ASC LIMIT ".$startPage.",".$pageCount;
$result = mysql_query($sql);
if(!empty($result)&&mysql_num_rows($result)>0){
	while($rows = mysql_fetch_assoc($result)){
		echo "<li>
					<span>[".$rows['addtime']."]</span>
					<span>[".$rows['type']."]</span>
				<a href=newsDetailed.php?id=".$rows['id'].">
				<img src='images/dt-0.gif' width='4'>".$rows['title']."</a>
				</li>";

	}}

	?>
</ul>
</div>
 <?php
		echo '<div class="tcdPageCode" >';
						echo '<a class="nextPage" href="./newsList.php?page=1">首页</a>';
						echo '<a class="nextPage" href="./newsList.php?page='.($page-1).'">上一页</a>';
						echo '当前'.$page.'页/共'.$allPage.'页';
						echo '<a class="nextPage" href="./newsList.php?page='.($page+1).'">下一页</a>';
						echo '<a class="nextPage" href="./newsList.php?page='.$allPage.'">尾页</a>';
	echo '</div>';
		 
?>
<script>var pc = 2</script></div>

</body>
</html>
